package org.javaqq.face.main.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import javax.swing.Icon;
import javax.swing.JLabel;

public class GnButton extends JLabel {
	private boolean flag=false;
	private Image image;
	
	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public GnButton(Icon icon){
		super(icon);
	}
	
	public GnButton(Image image){
		super("");
	}
	
	public GnButton(int size){
		super("");
	    setPreferredSize(new Dimension(size,size));
	}
	
	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	protected void paintComponent(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
		if (isFlag()) {
			Paint f = new GradientPaint(0.0f, 0.0f, new Color(255, 255, 255,
					100), 0, 50, new Color(255, 255, 255, 200), true);
			g2d.setPaint(f);
			// g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
			g2d.fillRoundRect(1, 1, this.getWidth() - 2, this.getHeight() - 2,
					3, 3);
			f=null;
		}
		
		g2d.drawImage(image, 5, 5, 18, 20, null);
	}
	
}
